package io.renren.modules.sharePage.controller;

import io.renren.common.utils.R;
import io.renren.modules.forYoung.entity.ForYounyEntity;
import io.renren.modules.sharePage.service.sharePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;

@RestController
public class sharePageController {
    @Autowired
    sharePageService sharePageService;

    @RequestMapping("/sharePage/{id}")
    @ResponseBody
    public R getSharePage(@PathVariable("id") Long id, HttpServletResponse response) throws UnsupportedEncodingException {
        ForYounyEntity sharePageEntity = sharePageService.getForyoungById(id);
        if(sharePageEntity!=null) {
            sharePageEntity.setNackName(new String(sharePageEntity.getNickNameB(), "utf-8"));
            sharePageEntity.setTitle(new String(sharePageEntity.getTitleB(), "utf-8"));
        }
        return  R.ok().put("data",sharePageEntity);
    }
}
